home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / Emulation_Include_Files / winsock.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  28.4 KB  |  853 lines

  1. /*++
  2. THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  3. ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  4. THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  5. PARTICULAR PURPOSE.
  6. Copyright (c) 1995-1998  Microsoft Corporation
  7.  
  8. Module Name:
  9.  
  10. winsock.h
  11.  
  12. Abstract:
  13.  
  14. Windows CE version of winsock.h.
  15.  
  16. Notes:
  17.  
  18.  
  19. --*/
  20. /*++
  21.  
  22.   This file includes parts which are Copyright (c) 1982-1986 Regents
  23.   of the University of California.  All rights reserved.  The
  24.   Berkeley Software License Agreement specifies the terms and
  25.   conditions for redistribution.
  26.  
  27. Module Name: winsock.h-definitions to be used with the WINSOCK.DLL
  28.  
  29. Purpose: This header file corresponds to version 1.1 of the Windows Sockets
  30. specification.
  31.  
  32. --*/
  33.  
  34. // @CESYSGEN IF CE_MODULES_WINSOCK
  35.  
  36. #ifndef _WINSOCKAPI_
  37. #define _WINSOCKAPI_
  38.  
  39. #include <windows.h>
  40.  
  41. #ifndef WINSOCKAPI
  42. #ifdef UNDER_NT
  43. #define WINSOCKAPI WINAPI
  44. #else
  45. #define WINSOCKAPI __cdecl
  46. #endif
  47. #endif
  48.  
  49. /*
  50.  * Basic system type definitions, taken from the BSD file sys/types.h.
  51.  */
  52. typedef unsigned char   u_char;
  53. typedef unsigned short  u_short;
  54. typedef unsigned int    u_int;
  55. typedef unsigned long   u_long;
  56.  
  57. /*
  58.  * The new type to be used in all
  59.  * instances which refer to sockets.
  60.  */
  61. typedef u_int           SOCKET;
  62.  
  63. /*
  64.  * Select uses arrays of SOCKETs.  These macros manipulate such
  65.  * arrays.  FD_SETSIZE may be defined by the user before including
  66.  * this file, but the default here should be >= 64.
  67.  *
  68.  * CAVEAT IMPLEMENTOR and USER: THESE MACROS AND TYPES MUST BE
  69.  * INCLUDED IN WINSOCK.H EXACTLY AS SHOWN HERE.
  70.  */
  71. #ifndef FD_SETSIZE
  72. #define FD_SETSIZE      64
  73. #endif /* FD_SETSIZE */
  74.  
  75. typedef struct fd_set {
  76.         u_int   fd_count;               /* how many are SET? */
  77.         SOCKET  fd_array[FD_SETSIZE];   /* an array of SOCKETs */
  78. } fd_set;
  79.  
  80. #ifdef __cplusplus
  81. extern "C" {
  82. #endif
  83.  
  84. extern int WINSOCKAPI __WSAFDIsSet(SOCKET, fd_set *);
  85.  
  86. #ifdef __cplusplus
  87. }
  88. #endif
  89.  
  90. #define FD_CLR(fd, set) do { \
  91.     u_int __i; \
  92.     for (__i = 0; __i < ((fd_set *)(set))->fd_count ; __i++) { \
  93.         if (((fd_set *)(set))->fd_array[__i] == fd) { \
  94.             while (__i < ((fd_set *)(set))->fd_count-1) { \
  95.                 ((fd_set *)(set))->fd_array[__i] = \
  96.                     ((fd_set *)(set))->fd_array[__i+1]; \
  97.                 __i++; \
  98.             } \
  99.             ((fd_set *)(set))->fd_count--; \
  100.             break; \
  101.         } \
  102.     } \
  103. } while(0)
  104.  
  105. #define FD_SET(fd, set) do { \
  106.     if ((! __WSAFDIsSet((SOCKET)fd, (fd_set *)set)) &&  \
  107.         (((fd_set *)(set))->fd_count < FD_SETSIZE)) \
  108.         ((fd_set *)(set))->fd_array[((fd_set *)(set))->fd_count++]=fd;\
  109. } while(0)
  110.  
  111. #define FD_ZERO(set) (((fd_set *)(set))->fd_count=0)
  112.  
  113. #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)fd, (fd_set *)set)
  114.  
  115. /*
  116.  * Structure used in select() call, taken from the BSD file sys/time.h.
  117.  */
  118. struct timeval {
  119.         long    tv_sec;         /* seconds */
  120.         long    tv_usec;        /* and microseconds */
  121. };
  122.  
  123. /*
  124.  * Operations on timevals.
  125.  *
  126.  * NB: timercmp does not work for >= or <=.
  127.  */
  128. #define timerisset(tvp)         ((tvp)->tv_sec || (tvp)->tv_usec)
  129. #define timercmp(tvp, uvp, cmp) \
  130.         ((tvp)->tv_sec cmp (uvp)->tv_sec || \
  131.          (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
  132. #define timerclear(tvp)         (tvp)->tv_sec = (tvp)->tv_usec = 0
  133.  
  134. /*
  135.  * Commands for ioctlsocket(),  taken from the BSD file fcntl.h.
  136.  *
  137.  *
  138.  * Ioctl's have the command encoded in the lower word,
  139.  * and the size of any in or out parameters in the upper
  140.  * word.  The high 2 bits of the upper word are used
  141.  * to encode the in/out status of the parameter; for now
  142.  * we restrict parameters to at most 128 bytes.
  143.  */
  144. #define IOCPARM_MASK    0x7ff            /* parameters must be < 2k bytes */
  145. #define    IOCGROUP(x)    (((x) >> 8) & 0xff)
  146. #define IOC_VOID        0x20000000      /* no parameters */
  147. #define IOC_OUT         0x40000000      /* copy out parameters */
  148. #define IOC_IN          0x80000000      /* copy in parameters */
  149. #define IOC_INOUT       (IOC_IN|IOC_OUT)
  150. #define    _IOC(inout,group,num,len) \
  151.     (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num))
  152. #define    _IO(g,n)    _IOC(IOC_VOID,    (g), (n), 0)
  153. #define    _IOR(g,n,t)    _IOC(IOC_OUT,    (g), (n), sizeof(t))
  154. #define    _IOW(g,n,t)    _IOC(IOC_IN,    (g), (n), sizeof(t))
  155. /* this should be _IORW, but stdio got there first */
  156. #define    _IOWR(g,n,t)    _IOC(IOC_INOUT,    (g), (n), sizeof(t))
  157.  
  158.  
  159. #define FIONREAD    _IOR('f', 127, u_long) /* get # bytes to read */
  160. #define FIONBIO     _IOW('f', 126, u_long) /* set/clear non-blocking i/o */
  161. #define FIOASYNC    _IOW('f', 125, u_long) /* set/clear async i/o */
  162.  
  163. /* Socket I/O Controls */
  164. #define SIOCSHIWAT  _IOW('s',  0, u_long)  /* set high watermark */
  165. #define SIOCGHIWAT  _IOR('s',  1, u_long)  /* get high watermark */
  166. #define SIOCSLOWAT  _IOW('s',  2, u_long)  /* set low watermark */
  167. #define SIOCGLOWAT  _IOR('s',  3, u_long)  /* get low watermark */
  168. #define SIOCATMARK  _IOR('s',  7, u_long)  /* at oob mark? */
  169.  
  170. /*
  171.  * Structures returned by network data base library, taken from the
  172.  * BSD file netdb.h.  All addresses are supplied in host order, and
  173.  * returned in network order (suitable for use in system calls).
  174.  */
  175.  
  176. struct  hostent {
  177.         char    * h_name;           /* official name of host */
  178.         char    * * h_aliases;  /* alias list */
  179.         short   h_addrtype;             /* host address type */
  180.         short   h_length;               /* length of address */
  181.         char    * * h_addr_list; /* list of addresses */
  182. #define h_addr  h_addr_list[0]          /* address, for backward compat */
  183. };
  184.  
  185. /*
  186.  * It is assumed here that a network number
  187.  * fits in 32 bits.
  188.  */
  189. struct  netent {
  190.         char    * n_name;           /* official name of net */
  191.         char    * * n_aliases;  /* alias list */
  192.         short   n_addrtype;             /* net address type */
  193.         u_long  n_net;                  /* network # */
  194. };
  195.  
  196. struct  servent {
  197.         char    * s_name;           /* official service name */
  198.         char    * * s_aliases;  /* alias list */
  199.         short   s_port;                 /* port # */
  200.         char    * s_proto;          /* protocol to use */
  201. };
  202.  
  203. struct  protoent {
  204.         char    * p_name;           /* official protocol name */
  205.         char    * * p_aliases;  /* alias list */
  206.         short   p_proto;                /* protocol # */
  207. };
  208.  
  209. /*
  210.  * Constants and structures defined by the internet system,
  211.  * Per RFC 790, September 1981, taken from the BSD file netinet/in.h.
  212.  */
  213.  
  214. /*
  215.  * Protocols
  216.  */
  217. #define IPPROTO_IP              0               /* dummy for IP */
  218. #define IPPROTO_ICMP            1               /* control message protocol */
  219. #define IPPROTO_GGP             2               /* gateway^2 (deprecated) */
  220. #define IPPROTO_TCP             6               /* tcp */
  221. #define IPPROTO_PUP             12              /* pup */
  222. #define IPPROTO_UDP             17              /* user datagram protocol */
  223. #define IPPROTO_IDP             22              /* xns idp */
  224. #define IPPROTO_ND              77              /* UNOFFICIAL net disk proto */
  225. #define IPPROTO_RAW             255             /* raw IP packet */
  226. #define IPPROTO_MAX             256
  227.  
  228. /*
  229.  * Port/socket numbers: network standard functions
  230.  */
  231. #define IPPORT_ECHO             7
  232. #define IPPORT_DISCARD          9
  233. #define IPPORT_SYSTAT           11
  234. #define IPPORT_DAYTIME          13
  235. #define IPPORT_NETSTAT          15
  236. #define IPPORT_FTP              21
  237. #define IPPORT_TELNET           23
  238. #define IPPORT_SMTP             25
  239. #define IPPORT_TIMESERVER       37
  240. #define IPPORT_NAMESERVER       42
  241. #define IPPORT_WHOIS            43
  242. #define IPPORT_MTP              57
  243.  
  244. /*
  245.  * Port/socket numbers: host specific functions
  246.  */
  247. #define IPPORT_TFTP             69
  248. #define IPPORT_RJE              77
  249. #define IPPORT_FINGER           79
  250. #define IPPORT_TTYLINK          87
  251. #define IPPORT_SUPDUP           95
  252.  
  253. /*
  254.  * UNIX TCP sockets
  255.  */
  256. #define IPPORT_EXECSERVER       512
  257. #define IPPORT_LOGINSERVER      513
  258. #define IPPORT_CMDSERVER        514
  259. #define IPPORT_EFSSERVER        520
  260.  
  261. /*
  262.  * UNIX UDP sockets
  263.  */
  264. #define IPPORT_BIFFUDP          512
  265. #define IPPORT_WHOSERVER        513
  266. #define IPPORT_ROUTESERVER      520
  267.                                         /* 520+1 also used */
  268.  
  269. /*
  270.  * Ports < IPPORT_RESERVED are reserved for
  271.  * privileged processes (e.g. root).
  272.  */
  273. #define IPPORT_RESERVED         1024
  274.  
  275. /*
  276.  * Link numbers
  277.  */
  278. #define IMPLINK_IP              155
  279. #define IMPLINK_LOWEXPER        156
  280. #define IMPLINK_HIGHEXPER       158
  281.  
  282. /*
  283.  * Internet address (old style... should be updated)
  284.  */
  285. struct in_addr {
  286.         union {
  287.                 struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
  288.                 struct { u_short s_w1,s_w2; } S_un_w;
  289.                 u_long S_addr;
  290.         } S_un;
  291. #define s_addr  S_un.S_addr
  292.                                 /* can be used for most tcp & ip code */
  293. #define s_host  S_un.S_un_b.s_b2
  294.                                 /* host on imp */
  295. #define s_net   S_un.S_un_b.s_b1
  296.                                 /* network */
  297. #define s_imp   S_un.S_un_w.s_w2
  298.                                 /* imp */
  299. #define s_impno S_un.S_un_b.s_b4
  300.                                 /* imp # */
  301. #define s_lh    S_un.S_un_b.s_b3
  302.                                 /* logical host */
  303. };
  304.  
  305. /*
  306.  * Definitions of bits in internet address integers.
  307.  * On subnets, the decomposition of addresses to host and net parts
  308.  * is done according to subnet mask, not the masks here.
  309.  */
  310. #define IN_CLASSA(i)            (((long)(i) & 0x80000000) == 0)
  311. #define IN_CLASSA_NET           0xff000000
  312. #define IN_CLASSA_NSHIFT        24
  313. #define IN_CLASSA_HOST          0x00ffffff
  314. #define IN_CLASSA_MAX           128
  315.  
  316. #define IN_CLASSB(i)            (((long)(i) & 0xc0000000) == 0x80000000)
  317. #define IN_CLASSB_NET           0xffff0000
  318. #define IN_CLASSB_NSHIFT        16
  319. #define IN_CLASSB_HOST          0x0000ffff
  320. #define IN_CLASSB_MAX           65536
  321.  
  322. #define IN_CLASSC(i)            (((long)(i) & 0xe0000000) == 0xc0000000)
  323. #define IN_CLASSC_NET           0xffffff00
  324. #define IN_CLASSC_NSHIFT        8
  325. #define IN_CLASSC_HOST          0x000000ff
  326.  
  327. #define INADDR_ANY              (u_long)0x00000000
  328. #define INADDR_LOOPBACK         0x7f000001
  329. #define INADDR_BROADCAST        (u_long)0xffffffff
  330. #define INADDR_NONE             0xffffffff
  331.  
  332. /*
  333.  * Socket address, internet style.
  334.  */
  335. struct sockaddr_in {
  336.         short   sin_family;
  337.         u_short sin_port;
  338.         struct  in_addr sin_addr;
  339.         char    sin_zero[8];
  340. };
  341.  
  342. #define WSADESCRIPTION_LEN      256
  343. #define WSASYS_STATUS_LEN       128
  344.  
  345. typedef struct WSAData {
  346.         WORD                    wVersion;
  347.         WORD                    wHighVersion;
  348.         char                    szDescription[WSADESCRIPTION_LEN+1];
  349.         char                    szSystemStatus[WSASYS_STATUS_LEN+1];
  350.         unsigned short          iMaxSockets;
  351.         unsigned short          iMaxUdpDg;
  352.         char FAR *              lpVendorInfo;
  353. } WSADATA;
  354.  
  355. typedef WSADATA FAR *LPWSADATA;
  356.  
  357. /*
  358.  * Options for use with [gs]etsockopt at the IP level.
  359.  */
  360. #define IP_OPTIONS      1               /* set/get IP per-packet options */
  361. #define IP_MULTICAST_IF     2           /* set/get IP multicast interface   */
  362. #define IP_MULTICAST_TTL    3           /* set/get IP multicast timetolive  */
  363. #define IP_MULTICAST_LOOP   4           /* set/get IP multicast loopback    */
  364. #define IP_ADD_MEMBERSHIP   5           /* add  an IP group membership      */
  365. #define IP_DROP_MEMBERSHIP  6           /* drop an IP group membership      */
  366.  
  367. #define IP_DEFAULT_MULTICAST_TTL   1    /* normally limit m'casts to 1 hop  */
  368. #define IP_DEFAULT_MULTICAST_LOOP  1    /* normally hear sends if a member  */
  369. #define IP_MAX_MEMBERSHIPS         20   /* per socket; must fit in one mbuf */
  370.  
  371. /*
  372.  * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
  373.  */
  374. struct ip_mreq {
  375.         struct in_addr  imr_multiaddr;  /* IP multicast address of group */
  376.         struct in_addr  imr_interface;  /* local IP address of interface */
  377. };
  378.  
  379. /*
  380.  * Definitions related to sockets: types, address families, options,
  381.  * taken from the BSD file sys/socket.h.
  382.  */
  383.  
  384. /*
  385.  * This is used instead of -1, since the
  386.  * SOCKET type is unsigned.
  387.  */
  388. #define INVALID_SOCKET  (SOCKET)(~0)
  389. #define SOCKET_ERROR            (-1)
  390.  
  391. /*
  392.  * Types
  393.  */
  394. #define SOCK_STREAM     1               /* stream socket */
  395. #define SOCK_DGRAM      2               /* datagram socket */
  396. #define SOCK_RAW        3               /* raw-protocol interface */
  397. #define SOCK_RDM        4               /* reliably-delivered message */
  398. #define SOCK_SEQPACKET  5               /* sequenced packet stream */
  399.  
  400. /*
  401.  * Option flags per-socket.
  402.  */
  403. #define SO_DEBUG        0x0001          /* turn on debugging info recording */
  404. #define SO_ACCEPTCONN   0x0002          /* socket has had listen() */
  405. #define SO_REUSEADDR    0x0004          /* allow local address reuse */
  406. #define SO_KEEPALIVE    0x0008          /* keep connections alive */
  407. #define SO_DONTROUTE    0x0010          /* just use interface addresses */
  408. #define SO_BROADCAST    0x0020          /* permit sending of broadcast msgs */
  409. #define SO_USELOOPBACK  0x0040          /* bypass hardware when possible */
  410. #define SO_LINGER       0x0080          /* linger on close if data present */
  411. #define SO_OOBINLINE    0x0100          /* leave received OOB data in line */
  412.  
  413. #define SO_DONTLINGER   (u_int)(~SO_LINGER)
  414.  
  415. /*
  416.  * Additional options.
  417.  */
  418. #define SO_SNDBUF       0x1001          /* send buffer size */
  419. #define SO_RCVBUF       0x1002          /* receive buffer size */
  420. #define SO_SNDLOWAT     0x1003          /* send low-water mark */
  421. #define SO_RCVLOWAT     0x1004          /* receive low-water mark */
  422. #define SO_SNDTIMEO     0x1005          /* send timeout */
  423. #define SO_RCVTIMEO     0x1006          /* receive timeout */
  424. #define SO_ERROR        0x1007          /* get error status and clear */
  425. #define SO_TYPE         0x1008          /* get socket type */
  426.  
  427. /*
  428.  * Option for opening sockets for synchronous access.
  429.  */
  430. #define SO_OPENTYPE     0x7008
  431.  
  432. /*
  433.  * Options and option values for creating a secure socket.
  434.  */
  435. #define SO_SECURE       0x2001          /* add security to socket */
  436. #define SO_SEC_NONE     0x2002          /* security not used on socket */
  437. #define SO_SEC_SSL      0x2004          /* use unified SSL/PCT for security */
  438.  
  439. /*
  440.  * TCP options.
  441.  */
  442. #define TCP_NODELAY     0x0001
  443. #define TCP_BSDURGENT   0x7000
  444.  
  445.  
  446. /*
  447.  * Address families.
  448.  */
  449.  //    NOTE: these AF_ types MUST match those in import\tdi.h TDI_ADDRESS_TYPE_ def's
  450.  // otherwise will not be able to correctly match addresses.
  451. #define AF_UNSPEC       0               /* unspecified */
  452. #define AF_UNIX         1               /* local to host (pipes, portals) */
  453. #define AF_INET         2               /* internetwork: UDP, TCP, etc. */
  454. #define AF_IMPLINK      3               /* arpanet imp addresses */
  455. #define AF_PUP          4               /* pup protocols: e.g. BSP */
  456. #define AF_CHAOS        5               /* mit CHAOS protocols */
  457. #define AF_NS           6               /* XEROX NS protocols */
  458. #define AF_IPX          6               /* IPX and SPX */
  459. #define AF_ISO          7               /* ISO protocols */
  460. #define AF_OSI          AF_ISO          /* OSI is ISO */
  461. #define AF_ECMA         8               /* european computer manufacturers */
  462. #define AF_DATAKIT      9               /* datakit protocols */
  463. #define AF_CCITT        10              /* CCITT protocols, X.25 etc */
  464. #define AF_SNA          11              /* IBM SNA */
  465. #define AF_DECnet       12              /* DECnet */
  466. #define AF_DLI          13              /* Direct data link interface */
  467. #define AF_LAT          14              /* LAT */
  468. #define AF_HYLINK       15              /* NSC Hyperchannel */
  469. #define AF_APPLETALK    16              /* AppleTalk */
  470. #define AF_NETBIOS      17              /* NetBios-style addresses */
  471. #define AF_PAGER        21                /* Pager addresses */    // WINCE this # to match TDI_ADDRESS types
  472. //#define AF_IRDA         22              /* IrDA - defined in af_irda.h*/
  473. #define AF_RBDS         23              /* RBDS */
  474.  
  475. #define AF_MAX          24
  476.  
  477. /*
  478.  * Structure used by kernel to store most
  479.  * addresses.
  480.  */
  481. struct sockaddr {
  482.         u_short sa_family;              /* address family */
  483.         char    sa_data[14];            /* up to 14 bytes of direct address */
  484. };
  485.  
  486. /*
  487.  * Structure used by kernel to pass protocol
  488.  * information in raw sockets.
  489.  */
  490. struct sockproto {
  491.         u_short sp_family;              /* address family */
  492.         u_short sp_protocol;            /* protocol */
  493. };
  494.  
  495. /*
  496.  * Protocol families, same as address families for now.
  497.  */
  498. #define PF_UNSPEC       AF_UNSPEC
  499. #define PF_UNIX         AF_UNIX
  500. #define PF_INET         AF_INET
  501. #define PF_IMPLINK      AF_IMPLINK
  502. #define PF_PUP          AF_PUP
  503. #define PF_CHAOS        AF_CHAOS
  504. #define PF_NS           AF_NS
  505. #define PF_IPX          AF_IPX
  506. #define PF_ISO          AF_ISO
  507. #define PF_OSI          AF_OSI
  508. #define PF_ECMA         AF_ECMA
  509. #define PF_DATAKIT      AF_DATAKIT
  510. #define PF_CCITT        AF_CCITT
  511. #define PF_SNA          AF_SNA
  512. #define PF_DECnet       AF_DECnet
  513. #define PF_DLI          AF_DLI
  514. #define PF_LAT          AF_LAT
  515. #define PF_HYLINK       AF_HYLINK
  516. #define PF_APPLETALK    AF_APPLETALK
  517.  
  518. #define PF_MAX          AF_MAX
  519.  
  520. /*
  521.  * Structure used for manipulating linger option.
  522.  */
  523. struct  linger {
  524.         u_short l_onoff;                /* option on/off */
  525.         u_short l_linger;               /* linger time */
  526. };
  527.  
  528. /*
  529.  * Level number for (get/set)sockopt() to apply to socket itself.
  530.  */
  531. #define SOL_SOCKET      0xffff          /* options for socket level */
  532.  
  533. /*
  534.  * Maximum queue length specifiable by listen.
  535.  */
  536. #define SOMAXCONN       5
  537.  
  538. #define MSG_OOB         0x1             /* process out-of-band data */
  539. #define MSG_PEEK        0x2             /* peek at incoming message */
  540. #define MSG_DONTROUTE   0x4             /* send without using routing tables */
  541.  
  542. #define MSG_MAXIOVLEN   16
  543.  
  544. #define    MSG_PARTIAL     0x8000          /* partial send or recv for message xport */
  545.  
  546. /*
  547.  * Define constant based on rfc883, used by gethostbyxxxx() calls.
  548.  */
  549. #define MAXGETHOSTSTRUCT        1024
  550.  
  551. /*
  552.  * Define flags to be used with the WSAAsyncSelect() call.
  553.  */
  554. #define FD_READ         0x01
  555. #define FD_WRITE        0x02
  556. #define FD_OOB          0x04
  557. #define FD_ACCEPT       0x08
  558. #define FD_CONNECT      0x10
  559. #define FD_CLOSE        0x20
  560.  
  561. /*
  562.  * All Windows Sockets error constants are biased by WSABASEERR from
  563.  * the "normal"
  564.  */
  565. #define WSABASEERR              10000
  566. /*
  567.  * Windows Sockets definitions of regular Microsoft C error constants
  568.  */
  569. #define WSAEINTR                (WSABASEERR+4)
  570. #define WSAEBADF                (WSABASEERR+9)
  571. #define WSAEACCES               (WSABASEERR+13)
  572. #define WSAEFAULT               (WSABASEERR+14)
  573. #define WSAEINVAL               (WSABASEERR+22)
  574. #define WSAEMFILE               (WSABASEERR+24)
  575.  
  576. /*
  577.  * Windows Sockets definitions of regular Berkeley error constants
  578.  */
  579. #define WSAEWOULDBLOCK          (WSABASEERR+35)
  580. #define WSAEINPROGRESS          (WSABASEERR+36)
  581. #define WSAEALREADY             (WSABASEERR+37)
  582. #define WSAENOTSOCK             (WSABASEERR+38)
  583. #define WSAEDESTADDRREQ         (WSABASEERR+39)
  584. #define WSAEMSGSIZE             (WSABASEERR+40)
  585. #define WSAEPROTOTYPE           (WSABASEERR+41)
  586. #define WSAENOPROTOOPT          (WSABASEERR+42)
  587. #define WSAEPROTONOSUPPORT      (WSABASEERR+43)
  588. #define WSAESOCKTNOSUPPORT      (WSABASEERR+44)
  589. #define WSAEOPNOTSUPP           (WSABASEERR+45)
  590. #define WSAEPFNOSUPPORT         (WSABASEERR+46)
  591. #define WSAEAFNOSUPPORT         (WSABASEERR+47)
  592. #define WSAEADDRINUSE           (WSABASEERR+48)
  593. #define WSAEADDRNOTAVAIL        (WSABASEERR+49)
  594. #define WSAENETDOWN             (WSABASEERR+50)
  595. #define WSAENETUNREACH          (WSABASEERR+51)
  596. #define WSAENETRESET            (WSABASEERR+52)
  597. #define WSAECONNABORTED         (WSABASEERR+53)
  598. #define WSAECONNRESET           (WSABASEERR+54)
  599. #define WSAENOBUFS              (WSABASEERR+55)
  600. #define WSAEISCONN              (WSABASEERR+56)
  601. #define WSAENOTCONN             (WSABASEERR+57)
  602. #define WSAESHUTDOWN            (WSABASEERR+58)
  603. #define WSAETOOMANYREFS         (WSABASEERR+59)
  604. #define WSAETIMEDOUT            (WSABASEERR+60)
  605. #define WSAECONNREFUSED         (WSABASEERR+61)
  606. #define WSAELOOP                (WSABASEERR+62)
  607. #define WSAENAMETOOLONG         (WSABASEERR+63)
  608. #define WSAEHOSTDOWN            (WSABASEERR+64)
  609. #define WSAEHOSTUNREACH         (WSABASEERR+65)
  610. #define WSAENOTEMPTY            (WSABASEERR+66)
  611. #define WSAEPROCLIM             (WSABASEERR+67)
  612. #define WSAEUSERS               (WSABASEERR+68)
  613. #define WSAEDQUOT               (WSABASEERR+69)
  614. #define WSAESTALE               (WSABASEERR+70)
  615. #define WSAEREMOTE              (WSABASEERR+71)
  616.  
  617. #define WSAEDISCON              (WSABASEERR+101)
  618.  
  619.  
  620. /*
  621.  * Extended Windows Sockets error constant definitions
  622.  */
  623. #define WSASYSNOTREADY            (WSABASEERR+91)
  624. #define WSAVERNOTSUPPORTED      (WSABASEERR+92)
  625. #define WSANOTINITIALISED       (WSABASEERR+93)
  626.  
  627.  
  628. /*
  629.  * Error return codes from gethostbyname() and gethostbyaddr()
  630.  * (when using the resolver). Note that these errors are
  631.  * retrieved via GetLastError() and must therefore follow
  632.  * the rules for avoiding clashes with error numbers from
  633.  * specific implementations or language run-time systems.
  634.  * For this reason the codes are based at WSABASEERR+1001.
  635.  * Note also that [WSA]NO_ADDRESS is defined only for
  636.  * compatibility purposes.
  637.  */
  638.  
  639. #define h_errno         GetLastError()
  640.  
  641. /* Authoritative Answer: Host not found */
  642. #define WSAHOST_NOT_FOUND       (WSABASEERR+1001)
  643. #define HOST_NOT_FOUND          WSAHOST_NOT_FOUND
  644.  
  645. /* Non-Authoritative: Host not found, or SERVERFAIL */
  646. #define WSATRY_AGAIN            (WSABASEERR+1002)
  647. #define TRY_AGAIN               WSATRY_AGAIN
  648.  
  649. /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
  650. #define WSANO_RECOVERY          (WSABASEERR+1003)
  651. #define NO_RECOVERY             WSANO_RECOVERY
  652.  
  653. /* Valid name, no data record of requested type */
  654. #define WSANO_DATA              (WSABASEERR+1004)
  655. #define NO_DATA                 WSANO_DATA
  656.  
  657. /* no address, look for MX record */
  658. #define WSANO_ADDRESS           WSANO_DATA
  659. #define NO_ADDRESS              WSANO_ADDRESS
  660.  
  661. /*
  662.  * Windows Sockets errors redefined as regular Berkeley error constants
  663.  */
  664. #define EWOULDBLOCK             WSAEWOULDBLOCK
  665. #define EINPROGRESS             WSAEINPROGRESS
  666. #define EALREADY                WSAEALREADY
  667. #define ENOTSOCK                WSAENOTSOCK
  668. #define EDESTADDRREQ            WSAEDESTADDRREQ
  669. #define EMSGSIZE                WSAEMSGSIZE
  670. #define EPROTOTYPE              WSAEPROTOTYPE
  671. #define ENOPROTOOPT             WSAENOPROTOOPT
  672. #define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
  673. #define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
  674. #define EOPNOTSUPP              WSAEOPNOTSUPP
  675. #define EPFNOSUPPORT            WSAEPFNOSUPPORT
  676. #define EAFNOSUPPORT            WSAEAFNOSUPPORT
  677. #define EADDRINUSE              WSAEADDRINUSE
  678. #define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
  679. #define ENETDOWN                WSAENETDOWN
  680. #define ENETUNREACH             WSAENETUNREACH
  681. #define ENETRESET               WSAENETRESET
  682. #define ECONNABORTED            WSAECONNABORTED
  683. #define ECONNRESET              WSAECONNRESET
  684. #define ENOBUFS                 WSAENOBUFS
  685. #define EISCONN                 WSAEISCONN
  686. #define ENOTCONN                WSAENOTCONN
  687. #define ESHUTDOWN               WSAESHUTDOWN
  688. #define ETOOMANYREFS            WSAETOOMANYREFS
  689. #define ETIMEDOUT               WSAETIMEDOUT
  690. #define ECONNREFUSED            WSAECONNREFUSED
  691. #define ELOOP                   WSAELOOP
  692. #define ENAMETOOLONG            WSAENAMETOOLONG
  693. #define EHOSTDOWN               WSAEHOSTDOWN
  694. #define EHOSTUNREACH            WSAEHOSTUNREACH
  695. #define ENOTEMPTY               WSAENOTEMPTY
  696. #define EPROCLIM                WSAEPROCLIM
  697. #define EUSERS                  WSAEUSERS
  698. #define EDQUOT                  WSAEDQUOT
  699. #define ESTALE                  WSAESTALE
  700. #define EREMOTE                 WSAEREMOTE
  701.  
  702. /* Socket function prototypes */
  703.  
  704. #ifdef __cplusplus
  705. extern "C" {
  706. #endif
  707.  
  708. SOCKET WINSOCKAPI accept (SOCKET s, struct sockaddr *addr,
  709.                           int *addrlen);
  710.  
  711. int WINSOCKAPI bind (SOCKET s, const struct sockaddr *addr, int namelen);
  712.  
  713. int WINSOCKAPI closesocket (SOCKET s);
  714.  
  715. int WINSOCKAPI connect (SOCKET s, const struct sockaddr *name, int namelen);
  716.  
  717. int WINSOCKAPI ioctlsocket (SOCKET s, long cmd, u_long *argp);
  718.  
  719. int WINSOCKAPI getpeername (SOCKET s, struct sockaddr *name,
  720.                             int * namelen);
  721.  
  722. int WINSOCKAPI getsockname (SOCKET s, struct sockaddr *name,
  723.                             int * namelen);
  724.  
  725. int WINSOCKAPI getsockopt (SOCKET s, int level, int optname,
  726.                            char * optval, int *optlen);
  727.  
  728. u_long WINSOCKAPI htonl (u_long hostlong);
  729.  
  730. u_short WINSOCKAPI htons (u_short hostshort);
  731.  
  732. unsigned long WINSOCKAPI inet_addr (const char * cp);
  733.  
  734. char * WINSOCKAPI inet_ntoa (struct in_addr in);
  735.  
  736. int WINSOCKAPI listen (SOCKET s, int backlog);
  737.  
  738. u_long WINSOCKAPI ntohl (u_long netlong);
  739.  
  740. u_short WINSOCKAPI ntohs (u_short netshort);
  741.  
  742. int WINSOCKAPI recv (SOCKET s, char * buf, int len, int flags);
  743.  
  744. int WINSOCKAPI recvfrom (SOCKET s, char * buf, int len, int flags,
  745.                          struct sockaddr *from, int * fromlen);
  746.  
  747. int WINSOCKAPI select (int nfds, fd_set *readfds, fd_set *writefds,
  748.                        fd_set *exceptfds, const struct timeval *timeout);
  749.  
  750. int WINSOCKAPI send (SOCKET s, const char * buf, int len, int flags);
  751.  
  752. int WINSOCKAPI sendto (SOCKET s, const char * buf, int len, int flags,
  753.                        const struct sockaddr *to, int tolen);
  754.  
  755. int WINSOCKAPI setsockopt (SOCKET s, int level, int optname,
  756.                            const char * optval, int optlen);
  757.  
  758. int WINSOCKAPI shutdown (SOCKET s, int how);
  759.  
  760. SOCKET WINSOCKAPI socket (int af, int type, int protocol);
  761.  
  762. /* Database function prototypes */
  763.  
  764. struct hostent * WINSOCKAPI gethostbyaddr(const char * addr,
  765.                                               int len, int type);
  766.  
  767. struct hostent * WINSOCKAPI gethostbyname(const char * name);
  768.  
  769. int WINSOCKAPI gethostname (char * name, int namelen);
  770.  
  771. /* Microsoft Windows Extension function prototypes */
  772. #ifdef _WIN32_WCE_EMULATION
  773. #define WSAStartup(wVersionRequired,lpWSAData)    \
  774.         ((lpWSAData)->wVersion=wVersionRequired,\
  775.         (lpWSAData)->wHighVersion=wVersionRequired,\
  776.         (lpWSAData)->szDescription[0]='\0',\
  777.         (lpWSAData)->szSystemStatus[0]='\0',\
  778.         (lpWSAData)->iMaxSockets=10,\
  779.         (lpWSAData)->iMaxUdpDg=0,\
  780.         (lpWSAData)->lpVendorInfo=NULL,(0))
  781. #define WSACleanup()            (0)
  782. #define WSASetLastError(iError)        SetLastError(iError)
  783. #define WSAGetLastError()        GetLastError()
  784. #else
  785. int WINSOCKAPI WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData);
  786.  
  787. int WINSOCKAPI WSACleanup(void);
  788.  
  789. #define WSASetLastError(iError)        SetLastError(iError)
  790.  
  791. #define WSAGetLastError()        GetLastError()
  792. #endif
  793.  
  794. int
  795. WINSOCKAPI // WSAAPI
  796. WSAIoctl(
  797.     IN  SOCKET  s,
  798.     IN  DWORD   dwIoControlCode,
  799.     IN  LPVOID  lpvInBuffer OPTIONAL,
  800.     IN  DWORD   cbInBuffer,
  801.     OUT LPVOID  lpvOutBuffer OPTIONAL,
  802.     IN  DWORD   cbOutBuffer,
  803.     OUT LPDWORD lpcbBytesReturned OPTIONAL,
  804.     IN  LPVOID lpOverlapped,
  805.     IN  LPVOID lpCompletionRoutine
  806.     );
  807.  
  808. #ifdef __cplusplus
  809. }
  810. #endif
  811.  
  812. /* Microsoft Windows Extended data types */
  813. typedef struct sockaddr SOCKADDR;
  814. typedef struct sockaddr *PSOCKADDR;
  815. typedef struct sockaddr *LPSOCKADDR;
  816.  
  817. typedef struct sockaddr_in SOCKADDR_IN;
  818. typedef struct sockaddr_in *PSOCKADDR_IN;
  819. typedef struct sockaddr_in *LPSOCKADDR_IN;
  820.  
  821. typedef struct linger LINGER;
  822. typedef struct linger *PLINGER;
  823. typedef struct linger *LPLINGER;
  824.  
  825. typedef struct in_addr IN_ADDR;
  826. typedef struct in_addr *PIN_ADDR;
  827. typedef struct in_addr *LPIN_ADDR;
  828.  
  829. typedef struct fd_set FD_SET;
  830. typedef struct fd_set *PFD_SET;
  831. typedef struct fd_set *LPFD_SET;
  832.  
  833. typedef struct hostent HOSTENT;
  834. typedef struct hostent *PHOSTENT;
  835. typedef struct hostent *LPHOSTENT;
  836.  
  837. typedef struct servent SERVENT;
  838. typedef struct servent *PSERVENT;
  839. typedef struct servent *LPSERVENT;
  840.  
  841. typedef struct protoent PROTOENT;
  842. typedef struct protoent *PPROTOENT;
  843. typedef struct protoent *LPPROTOENT;
  844.  
  845. typedef struct timeval TIMEVAL;
  846. typedef struct timeval *PTIMEVAL;
  847. typedef struct timeval *LPTIMEVAL;
  848.  
  849.  
  850. #endif  /* _WINSOCKAPI_ */
  851.  
  852. // @CESYSGEN ENDIF
  853.